import { BaseSkill } from '../BaseSkill';
import { DamageType, SkillType } from '../../types';
import { General } from '../../models/General';
import { Battle } from '../../models/Battle';

export class TanXiaoZhuXin extends BaseSkill {
  private readonly DAMAGE_RATIO = 0.8;

  constructor() {
    super(
      'tanXiaoZhuXin',
      '谈笑诛心',
      SkillType.Active,
      DamageType.Strategy,
      0.4,  // 40% 触发概率
      3,    // 3回合CD
      2     // 2回合持续
    );
  }

  execute(source: General, battle: Battle): void {
    if (!this.canUse() || Math.random() > this.probability) return;

    const target = battle.selectTarget(source);
    if (target) {
      const damage = source.attributes.intelligence * this.DAMAGE_RATIO;
      target.receiveDamage(damage);
    }

    this.startCooldown();
  }
}
